//
//  YPAccountTableViewCell.m
//  ChengHuiTong
//
//  Created by ypwl on 15/11/4.
//  Copyright © 2015年 张文权. All rights reserved.
//

#import "YPAccountTableViewCell.h"

@implementation YPAccountTableViewCell{
    
    UILabel*_styleLabel;
    UILabel*_freezeMoney;
    UILabel*_operateMoney;
    UILabel*_timeLabel;
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {

        _styleLabel=[[UILabel alloc] initWithFrame:CGRectMake(leftMargin, 10, (SCREEN_WIDTH - leftMargin*2)/2.f, 20)];
        _styleLabel.font=[UIFont systemFontOfSize:autoScaleW(15)];
        [self.contentView addSubview:_styleLabel];
        
        
        _operateMoney=[[UILabel alloc] initWithFrame:CGRectMake(_styleLabel.right, _styleLabel.top, _styleLabel.width, _styleLabel.height)];
        _operateMoney.textColor = kColor_greyAshTitleColor;
        _operateMoney.font=[UIFont systemFontOfSize:autoScaleW(13)];
        [self.contentView addSubview:_operateMoney];

        
        _freezeMoney=[[UILabel alloc] initWithFrame:CGRectMake(_operateMoney.left, _operateMoney.bottom + 3, _operateMoney.width, _operateMoney.height)];
        _freezeMoney.textColor = _operateMoney.textColor;
        _freezeMoney.font=_operateMoney.font;
        [self.contentView addSubview:_freezeMoney];

        
        _timeLabel=[[UILabel alloc] initWithFrame:CGRectMake(_styleLabel.left, _freezeMoney.top, _styleLabel.width, _styleLabel.height)];
        _timeLabel.textColor = _operateMoney.textColor;
        _timeLabel.font=_operateMoney.font;
        [self.contentView addSubview:_timeLabel];
  
    }
    
    return self;
    
}


-(void)layoutSubviews{
    
    [super layoutSubviews];
    
    _timeLabel.text=[LGToolMethods stringFromInterval:[_accountModel.addtime doubleValue] withFormate:@"yyyy-MM-dd HH:mm:ss"];
    _styleLabel.text=_accountModel.type;
    _freezeMoney.attributedText = [self getAttributedStringWithOriginalString:[NSString stringWithFormat:@"冻结金额 :  %@元",_accountModel.freeze_money]
                                                                 changeString:[NSString stringWithFormat:@"%@元",_accountModel.freeze_money]];
    
    _operateMoney.attributedText = [self getAttributedStringWithOriginalString:[NSString stringWithFormat:@"操作金额 :  %@元",_accountModel.money]
                                                                 changeString:[NSString stringWithFormat:@"%@元",_accountModel.money]];
    
}

- (NSAttributedString *)getAttributedStringWithOriginalString:(NSString *)originalString
                                                  changeString:(NSString *)changeString
{
    
    NSMutableAttributedString *mAttString = [[NSMutableAttributedString alloc]initWithString:originalString];
    [mAttString addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:autoScaleW(15)],
                                NSForegroundColorAttributeName:[UIColor blackColor],
                                } range:[originalString rangeOfString:changeString]];
    return mAttString;
}


@end
